package demo02;
import java.util.ArrayList;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-25
 * Time: 21:49
 */
public class demo03 {
    public List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> one = new ArrayList<>();
        one.add(1);
        ret.add(one);
        for (int i = 1; i < numRows; i++) {
            List<Integer> curRows = new ArrayList<>();
            curRows.add(1);
            for(int j=1; j<i ;j++) {
                List<Integer> prev = ret.get(i-1);
                curRows.add( prev.get(j-1) + prev.get(j));
            }
            curRows.add(1);
            ret.add(curRows);
        }
        return ret;
    }

}
